/* Shared library add-on to iptables to add IPMAC support. */
#include <stdio.h>
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>
#include <iptables.h>

//#include <config/ip/nf/iptables.h>
#include <linux/netfilter_ipv4/ip_conntrack.h>
#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter.h>

/* Function which prints out usage message. */
static void
help(void)
{
	printf("IPMAC  options: no options\n");
}

static struct option opts[] = {
	{0}
};

/* Initialize the match. */
static void
init(struct ipt_entry_match *m, unsigned int *nfcache)
{
	/* Can't cache this */
	*nfcache |= NFC_UNKNOWN;
}


/* Function which parses command options; returns true if it
   ate an option */
static int
parse(int c, char **argv, int invert, unsigned int *flags,
                     const struct ipt_entry *entry,
                     unsigned int *nfcache,
                     struct ipt_entry_match **match)
{
	return 0;
}

/* Final check; must have specified --state. */
static void final_check(unsigned int flags)
{
}

/* Prints out the matchinfo. */
static void
print(const struct ipt_ip *ip,
      const struct ipt_entry_match *match, int numeric)
{
	printf("IPMAC");
}

/* Saves the matchinfo in parsable form to stdout. */ 
static void
save(const struct ipt_ip *ip, const struct ipt_entry_match *match)
{
}


static struct iptables_match IPMAC = {
        .next           = NULL,
        .name           = "IPMAC",
        .version        = IPTABLES_VERSION,
        .size           = IPT_ALIGN(0),
        .userspacesize  = IPT_ALIGN(0),
        .help           = &help,
        .init           = &init,
        .parse          = &parse,
        .final_check    = &final_check,
        .print          = &print,
        .save           = &save,
        .extra_opts     = opts
};

void _init(void)
{
	register_match(&IPMAC);
}
